<?php

namespace app\modules\lenders\models;

use Yii;

/**
 * This is the model class for table "rah_combox".
 *
 * @property integer $comboxID
 * @property string $comboxName
 * @property string $itemName
 * @property string $itemValue
 * @property integer $orderNo
 */
class Combox extends \yii\db\ActiveRecord {

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'rah_combox';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['orderNo'], 'integer'],
            [['comboxName'], 'string', 'max' => 20],
            [['itemName', 'itemValue'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'comboxID' => 'Combox ID',
            'comboxName' => 'Combox Name',
            'itemName' => 'Item Name',
            'itemValue' => 'Item Value',
            'orderNo' => 'Order No',
        ];
    }

    /**
     * 获取combox下拉框数据
     * @param type $type
     * @return type
     */
    public static function getComboxName($type = '') {
        $combox = self::find()->where(['comboxName' => $type])->all();
        if ($type == '开户状态') {
            if (isset($combox)) {
                return \yii\helpers\ArrayHelper::map($combox, 'itemValue', 'itemName');
            }
        }
        if (isset($combox)) {
            return \yii\helpers\ArrayHelper::map($combox, 'orderNo', 'itemName');
        }
    }

}
